/*****************************************************************************
 * plum_assert.h
 *
 * Copyright (C) 2020 Jeasonvor 1101627719@qq.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 ****************************************************************************/
#ifndef __PLUM_ASSERT_H__
#define __PLUM_ASSERT_H__

/*****************************************************************************
 * Included Files
 ****************************************************************************/

/*****************************************************************************
 * Pre-processor Definitions
 ****************************************************************************/

/**
 * @brief:  断言，如果expr为真，则什么都不执行
 *               如果expr为假，则终止程序
 */
#define PLUM_ASSERT(expr) \
    (expr) ?: plum_assert(PLUM_STRING(expr), PLUM_FUNC, PLUM_LINE)
/*****************************************************************************
 * Public Types
 ****************************************************************************/

/*****************************************************************************
 * Public Data
 ****************************************************************************/

/****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
 * Public Function Prototypes
 ****************************************************************************/

/**
 * @brief:  plum断言
 *
 * @param[in]:  disc    -   判断条件
 * @param[in]:  func    -   函数名字
 * @param[in]:  line    -   行号
 *
 * @return
 *
 * @note:   此函数不支持外部调用，打断言用PLUM_ASSERT宏代替
 */
plum_void plum_assert(plum_s8 *disc, plum_s8 *func, plum_u32 line);

/****************************************************************************/
#ifdef __cplusplus
}
#endif
/****************************************************************************/
#endif /* __PLUM_ASSERT_H__ */
/****************************************************************************/
/*                                                                          */
/*  End of file.                                                            */
/*                                                                          */
/****************************************************************************/
